
jQuery(document).ready(function(){

    function datepicked(jQuery) {
        var fromDate = jQuery('#desde').datepicker('getDate');
        var toDate = jQuery('#hasta').datepicker('getDate');
        if (fromDate && toDate) {
            var difference_msec = toDate.getTime() - fromDate.getTime();
            var difference_days = difference_msec / 86400000;
            jQuery("#nights").val(Math.ceil(difference_days));
        }
    }
jQuery('#desde').datepicker({
    dateFormat: 'dd/mm/yy',
       showOn: "button",
       buttonImage: "images/img_plantilla/ico-calendario.png",
       buttonImageOnly: true,
       monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
       monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
                'Jul','Ago','Sep','Oct','Nov','Dic'],
       dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
       dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Jue','Vie','Sab'],
       dayNamesMin: ['D','L','M','M','J','V','S'],
        onSelect: function(dateStr) {
            var d1 = jQuery(this).datepicker("getDate");
            d1.setDate(d1.getDate() + 0); // change to + 1 if necessary
            var d2 = jQuery(this).datepicker("getDate");
          //  d2.setDate(d2.getDate() + 700); // change to + 29 if necessary
            jQuery("#hasta").datepicker("setDate", null);
            jQuery("#hasta").datepicker("option", "minDate", d1);
            //jQuery("#hasta").datepicker("option", "maxDate", d2);
            datepicked();
        }   
});

jQuery('#desde').click(function(){
jQuery('#desde').datepicker("show");
});

jQuery('#hasta').datepicker({
    dateFormat: 'dd/mm/yy',
        showOn: "button",
        buttonImage: "images/img_plantilla/ico-calendario.png",
        buttonImageOnly: true,
        monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
       monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
                'Jul','Ago','Sep','Oct','Nov','Dic'],
       dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
       dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Jue','Vie','Sab'],
       dayNamesMin: ['D','L','M','M','J','V','S'],
        onSelect: function(dateStr) {
            datepicked();
        }    
});

function datepicked2() {
        var fromDate = jQuery('#desde2').datepicker('getDate');
        var toDate = jQuery('#hasta2').datepicker('getDate');
        if (fromDate && toDate) {
            var difference_msec = toDate.getTime() - fromDate.getTime();
            var difference_days = difference_msec / 86400000;
            jQuery("#nights").val(Math.ceil(difference_days));
        }
    }
jQuery('#desde2').datepicker({
     dateFormat: 'dd/mm/yy',
       showOn: "button",
       buttonImage: "images/img_plantilla/ico-calendario.png",
       buttonImageOnly: true,
       monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
       monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
                'Jul','Ago','Sep','Oct','Nov','Dic'],
       dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
       dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Jue','Vie','Sab'],
       dayNamesMin: ['D','L','M','M','J','V','S'],
        onSelect: function(dateStr) {
            var d1 = jQuery(this).datepicker("getDate");
            d1.setDate(d1.getDate() + 0); // change to + 1 if necessary
            var d2 = jQuery(this).datepicker("getDate");
             d2.setDate(d2.getDate() + 700); // change to + 29 if necessary
            jQuery("#hasta2").datepicker("setDate", null);
            jQuery("#hasta2").datepicker("option", "minDate", d1);
            jQuery("#hasta2").datepicker("option", "maxDate", d2);
            datepicked2();
        }
});

jQuery('#desde2').click(function(){
jQuery('#desde2').datepicker("show");
});

jQuery('#hasta2').datepicker({
    dateFormat: 'dd/mm/yy',
        showOn: "button",
        buttonImage: "images/img_plantilla/ico-calendario.png",
        buttonImageOnly: true,
       monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
       monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
                'Jul','Ago','Sep','Oct','Nov','Dic'],
       dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
       dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Jue','Vie','Sab'],
       dayNamesMin: ['D','L','M','M','J','V','S'],
        onSelect: function(dateStr) {
            datepicked2();
        }    
});

jQuery('#desde3').datepicker({
    dateFormat: 'dd/mm/yy',
        showOn: "button",
        buttonImage: "images/img_plantilla/ico-calendario.png",
        buttonImageOnly: true,
       monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
       monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
                'Jul','Ago','Sep','Oct','Nov','Dic'],
       dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
       dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Jue','Vie','Sab'],
       dayNamesMin: ['D','L','M','M','J','V','S']
         
});


    
    
      jQuery(".numeros").keypress(function(event){
        
          if(event.which){
                     return (event.which > 47 && event.which < 58 || event.which == 8);
                 }else if(event.charCode){
                     return (event.charCode > 47 && event.charCode < 58 || event.charCode == 8);
                 }else if(window.event.keyCode){
                     return (window.event.keyCode > 47 && window.event.keyCode < 58 || window.event.keyCode == 8);
                 }
                 
          
      });
      
      
      
      
     jQuery(".alfanumerico").keypress(function(event){
        
          if(event.which){
                    if(event.which > 64 && event.which < 91 || event.which == 8){
                         return true;
                     }else
                     if(event.which > 96 && event.which < 123 || event.which == 8){
                         return true;
                     }else
                     if(event.which > 47 && event.which < 58 || event.which == 8){
                         return true;
                     }else{
                         return false;
                     }
                     
         } 
         
         
           
         if(event.charCode){
                     if(event.charCode > 64 && event.charCode < 91 || event.charCode == 8){
                         return true;
                     }else
                     if(event.charCode > 96 && event.charCode < 123 || event.charCode == 8){
                         return true;
                     }else
                     if(event.charCode > 47 && event.charCode < 58 || event.charCode == 8){
                         return true;
                     }else{
                         return false;
                     }
         }        
         if(window.event.keyCode){
                     
                     if(window.event.keyCode > 64 && window.event.keyCode < 91 || window.event.keyCode == 8){
                         return true;
                     }else
                     if(window.event.keyCode > 96 && window.event.keyCode < 123 || window.event.keyCode == 8){
                         return true;
                     }else
                     if(window.event.keyCode > 47 && window.event.keyCode < 58 || window.event.keyCode == 8){
                         return true;
                     }else{
                         return false;
                     }
                       
                     
                     


           }
                 
          
      });
      
      
      
      
      jQuery(".alfa_mayus").keypress(function(event){
        
          if(event.which){
                    if(event.which > 64 && event.which < 91 || event.which == 8){
                         return true;
                     }else
                     if(event.which > 47 && event.which < 58 || event.which == 8){
                         return true;
                     }else{
                         return false;
                     }
                     
         } 
         
         
           
         if(event.charCode){
                     if(event.charCode > 64 && event.charCode < 91 || event.charCode == 8){
                         return true;
                     }else
                     if(event.charCode > 47 && event.charCode < 58 || event.charCode == 8){
                         return true;
                     }else{
                         return false;
                     }
         }        
         if(window.event.keyCode){
                     
                     if(window.event.keyCode > 64 && window.event.keyCode < 91 || window.event.keyCode == 8){
                         return true;
                     }else
                     if(window.event.keyCode > 47 && window.event.keyCode < 58 || window.event.keyCode == 8){
                         return true;
                     }else{
                         return false;
                     }
                       
                     
                     


           }
                 
          
      });
      
      
      
      
      jQuery(".letras").keypress(function(event){
        
          if(event.which){
                    if(event.which > 64 && event.which < 91 || event.which == 8){
                         return true;
                     }else
                     if(event.which > 96 && event.which < 123 || event.which == 8){
                         return true;
                     }else{
                         return false;
                     }
                     
         } 
           
         if(event.charCode){
                     if(event.charCode > 64 && event.charCode < 91 || event.charCode == 8){
                         return true;
                     }else
                     if(event.charCode > 96 && event.charCode < 123 || event.charCode == 8){
                         return true;
                     }else{
                         return false;
                     }
         }        
         if(window.event.keyCode){
                     
                     if(window.event.keyCode > 64 && window.event.keyCode < 91 || window.event.keyCode == 8){
                         return true;
                     }else
                     if(window.event.keyCode > 96 && window.event.keyCode < 123 || window.event.keyCode == 8){
                         return true;
                     }else{
                         return false;
                     }
                       
                     
                     


           }
                 
          
      });


      jQuery('.fecha_ocho').mask('00/00/00');
      jQuery('.num_nit').mask('0000-000000-000-0');
     jQuery('.num_dui').mask('00000000-0');
     jQuery('.num_decimal').mask('00.00');
       jQuery('.fecha_dies').mask('00/00/0000');
       
  });


	

	